package cn.kgc.springcloud.controller;

import cn.kgc.springcloud.client.OrderClient;
import cn.kgc.springcloud.entity.Order;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;

/**
 * @author 课工场
 * @date 2024/4/28
 * @description
 */
@RestController
@RequestMapping("user")
public class UserController {

    @Resource
    private OrderClient orderClient;

    @RequestMapping("m1")
    public String method1() {
        //  ->  http://localhosrt:8556/order/m1

        String s = orderClient.method1();
        return "userService ok >> order >> "+s;
    }

    @RequestMapping("m2")
    public String method2(Integer uid) {

        System.out.println("uid = " + uid);
        String s = orderClient.method2(uid);

        return "userService ok >> order >> "+s;
    }

    @RequestMapping("m3")
    public String method3(Integer uid) {

        System.out.println("uid = " + uid);
        String s = orderClient.method3(uid);

        return "userService ok >> order >> "+s;
    }

    @RequestMapping("m4")
    public String method4(Integer id,String name) {

        System.out.println("id = " + id + ", name = " + name);
        String s = orderClient.method4(id, name);
        return "userService ok >> order >> "+s;
    }

    @RequestMapping("m5")
    public String method5(Order order) {

        System.out.println("order = " + order);

        String s = orderClient.method5(order);

        return "userService ok >> order >> "+s;
    }

    @RequestMapping("m6")
    public String method6(Integer[] ids) {

        String string = Arrays.toString(ids);
        System.out.println("string = " + string);

        String s = orderClient.method6(ids);

        return "userService ok >> order >> "+s;
    }


    @RequestMapping("m7")
    public List<Order> method7(Integer uid) {

        // json ->  list
        List<Order> orders = orderClient.method7(uid);

        return orders;
    }


    @RequestMapping("m8")
    public Order method8(Integer id) {

        Order order = orderClient.method8(id);
        return order;
    }
}
